package job.manager.client.servlets;

import java.util.Collection;
import org.jdom.*;

/**
 *  Helps creating a jdom document from strings, that follows the xml schema standard
 *  that is specified in http://job.manager/schema/WeekSchedule.
 * 
 */
public class ReportTimeHelper {

    public static final Namespace ns = org.jdom.Namespace.getNamespace("ns1", "http://job.manager/schema/WeekSchedule");

    public ReportTimeHelper() {
    }

    //create a new day event
    public Element getDayEvent(String title, String description, String startTime) {

        Element root = new Element("dayEvent", ns);

        root.setAttribute("Title", title);
        root.setAttribute("Description", description);
        root.setAttribute("Time", startTime);
        return root;
    }

    //creating a new day
    public Element getDay(String date, Collection<Element> e) {
        Element root = new Element("day", ns);

        root.setAttribute("date", date);
        root.addContent(e);
        return root;
    }

    //creating a new week
    public Element getWeek(String weekNumber, Collection<Element> e) {
        Element root = new Element("week", ns);

        root.setAttribute("weekNumber", weekNumber);
        root.addContent(e);
        return root;
    }
    //get a document of the Week's that are inserted
    public Document getWeekList(Collection<Element> e) {
        Namespace xsiNS = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");

        Element root = new Element("weekList", ns);

        root.setAttribute("schemaLocation", "http://job.manager/schema/WeekSchedule WeekSchedule.xsd", xsiNS);

        root.addContent(e);
        Document doc = new Document();
        doc.addContent(root);

        return doc;
    }
}